<?php if(!defined('PHPOK_SET')){die('<h3>Error...</h3>');}?><?php $APP->tpl->p("head","","0");?>
<style id="loading-style">html,body{width:100%;height:100%; overflow: hidden;}</style>

<div class="ad"><img src="<?php echo $_sys[sharetips];?>" alt="" /></div>
<section class="main animated">
	<div class="main-box">
		<?php if($_SESSION['user_id']){?>
		<div class="home-info border-box fn-clear">
			<figure class="figure-box">
				<img src="<?php if($urs[headimgurl]){?><?php echo urldecode($urs[headimgurl]);?><?php }else{ ?>tpl/www/images/header.png<?php } ?>" alt="" />
			</figure>
			<h5><?php echo $urs[username];?>&nbsp;</h5>
			<div class="user-info">
				<label>总佣金</label>
				<p><i class="icon icon-money"></i><span><?php echo $money;?></span></p>
			</div>
			<div class="info-border"></div>
			<div class="user-info">
				<label>客户数</label>
				<p><i class="icon icon-users"></i><span><?php echo $total;?></span></p>
			</div>
			<?php if($urs[fxstatus]){?>
			<div class="user-ad-yes">
				<p><a href="<?php echo $_sys[shareyeslink];?>" title="<?php echo $_sys[sharegiftyes];?>"><?php echo $_sys[sharegiftyes];?></a></p>
			</div>
			<?php }else{ ?>
			<div class="user-ad">
				<p><a href="javascript:void(0)" id="dialog"><?php echo $_sys[sharegift];?></a></p>
			</div>
			<?php } ?>
			<a href="<?php if($_SESSION['user_id']){?><?php echo site_url('usercp');?><?php }else{ ?><?php echo site_url('login');?><?php } ?>" title="设置" class="jjr-setting"><i class="icon-setting"></i></a>
		</div>
		<?php }else{ ?>
		<div class="unregister">
			<figure><a href="<?php echo site_url('register');?>"><img src="tpl/www/images/unregister.jpg" alt="" /></a></figure>
		</div>
		<?php } ?>
		<ul class="home-nav fn-clear">
			<li class="nav-recommend"><a href="<?php if($_SESSION['user_id']){?><?php echo site_url('recommend');?><?php }else{ ?><?php echo site_url('register');?><?php } ?>" title="<?php echo $_sys[tj_title];?>"><?php echo $_sys[tj_title];?><label>hot</label><br /><span>Recommend</span></a></li>
			<li class="nav-rule"><a href="<?php if($_SESSION['user_id']){?><?php echo site_url('customer');?><?php }else{ ?><?php echo site_url('login');?><?php } ?>" title="<?php echo $_sys[kh_title];?>"><?php echo $_sys[kh_title];?><br /><span>Client</span></a></li>
			<li class="nav-commission"><a href="<?php if($_SESSION['user_id']){?><?php echo site_url('commission');?><?php }else{ ?><?php echo site_url('login');?><?php } ?>" title="<?php echo $_sys[yj_title];?>"><p><?php echo $_sys[yj_title];?><br /><span>Commission</span></p></a></li>
			<li class="nav-rule-detail"><a href="<?php echo site_url('msg','id=2');?>" title="<?php echo $_sys[xz_title];?>"><?php echo $_sys[xz_title];?><br /><span>Rule</span></a></li>
		</ul>
	</div>
</section>
<footer class="foot"><a href="<?php echo $_sys[siteurl];?>">&copy; Powered by <?php echo $_sys[copyright];?></a></footer>
<script src="http://g.tbcdn.cn/kissy/k/1.4.0/seed.js"></script>
<script src="js/mod.jjr.js"></script>
<script src="js/jquery-1.8.2.min.js" type="text/javascript"></script>
<?php
	include(LIBS.'/WeixinJs/WeixinJs.class.php');  
	$weixinJs = new \WeixinJs("wxa9adc2cde1638e75","ac5418ff04ffcc3e0bb05c38bff32821");
	$signPackage = $weixinJs->GetSignPackage();
	$appId = $signPackage['appId'];
	$timestamp = $signPackage['timestamp'];
	$nonceStr = $signPackage['nonceStr'];
	$signature = $signPackage['signature'];

	$signPackage['sharetitle'] = $_sys['wx_title'];
	$signPackage['slink'] = $_sys['wx_link'];
	$signPackage['sharedesc'] = $_sys['wx_description'];
	$signPackage['sharepic'] = $_sys['siteurl'].$_sys['wx_logo'];

?>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
	// 注意：所有的JS接口只能在公众号绑定的域名下调用，公众号开发者需要先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”。 
	// 如果发现在 Android 不能分享自定义内容，请到官网下载最新的包覆盖安装，Android 自定义分享接口需升级至 6.0.2.58 版本及以上。
	// 完整 JS-SDK 文档地址：http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html
	wx.config({
		debug: false,
		appId: '<?php echo $signPackage['appId'];?>',
		timestamp: <?php echo $signPackage['timestamp'];?>,
		nonceStr: '<?php echo $signPackage['nonceStr'];?>',
		signature: '<?php echo $signPackage['signature'];?>',
		jsApiList: [
		'checkJsApi',
		'onMenuShareTimeline',
		'onMenuShareAppMessage'
		]
	});
	
	wx.ready(function () {
		// 在这里调用 API
		//监听“分享到朋友圈”按钮点击
		//desc:"<?php echo $signPackage['sharedesc'];?>",
		wx.onMenuShareTimeline({
			title: "<?php echo $signPackage['sharetitle'];?>",
			link:"<?php echo $signPackage['slink'];?>",
			imgUrl: "<?php echo $signPackage['sharepic'];?>",
			trigger: function (res) {
				// 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
				1;
			},
			success: function (res) {
				var pars = "";
				var parsprams = "";
				var randomcode = Math.random() * 100000;
				parsprams = pars + "&code=" + randomcode + "&f=updategroup";
				$.ajax({
					url: 'index.php?c=home',
					type: "Get",
					data: parsprams,
					beforeSend: function () { },
					success: function (state) {
						alert(state);
					}
				});		
			},
			cancel: function (res) {
				alert("您取消了分享！");
			}
		});
		//监听“发送给朋友”按钮点击
		wx.onMenuShareAppMessage({
			title: "<?php echo $signPackage['sharetitle'];?>",
			link:"<?php echo $signPackage['slink'];?>",
			desc:"<?php echo $signPackage['sharedesc'];?>",
			imgUrl: "<?php echo $signPackage['sharepic'];?>",
			trigger: function (res) {
				// 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
				1;
			},
			success: function (res) {
				var pars = "";
				var parsprams = "";
				var randomcode = Math.random() * 100000;
				parsprams = pars + "&code=" + randomcode + "&f=updategroup";
				$.ajax({
					url: 'index.php?c=home',
					type: "Get",
					data: parsprams,
					beforeSend: function () { },
					success: function (state) {
						alert(state);
						window.reload();
					}
				});		
			},
			cancel: function (res) {
				alert("您取消了分享！");
			}
		});
	});
</script>
</body>
</html>